package com.wzdigit.wms.basic.enums;

import java.util.*;

/**
 * 调拨单单号编码规则
 */
public enum TransferNoCodeEnum implements BaseEnum {

	TRANSFER("TRANSFER_T01", "转仓", "TransferType"),
	SECOND_STEP_TRANSFER("TRANSFER_T02", "仓库间调拨（二步调拨）", "TransferType"),
	BETWEEN_FACTORY_TRANSFER("TRANSFER_T03", "组织间调拨", "TransferType"),
	SO_NO_TRANSFER("TRANSFER_T04", "销售订单调拨", "TransferType"),
	BORROW_TRANSFER("TRANSFER_T05", "借机", "TransferType"),
	BACK_TRANSFER("TRANSFER_T06", "还机", "TransferType"),
	GOODSCONVER_TRANSFER("TRANSFER_T11", "物料属性变更", "TransferType");


    /**
     * 枚举值
     */
    public String code;

    /**
     * 枚举名称
     */
    public String enumName;

    /**
     * 枚举实体类属性描述
     */
    public String description;
    
    public static String text;

    TransferNoCodeEnum(String enumName, String description) {
        this.enumName = enumName;
        this.description = description;
    }

    TransferNoCodeEnum(String code, String enumName, String description) {
        this.code = code;
        this.enumName = enumName;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public static TransferNoCodeEnum getEnumByCode(String enumCode) {
        TransferNoCodeEnum[] values = TransferNoCodeEnum.values();
        TransferNoCodeEnum samplingEnum = null;

        for (TransferNoCodeEnum value : values) {
            if (value.getCode().equals(enumCode)) {
                samplingEnum = value;
            }
        }
        return samplingEnum;
    }

    public static TransferNoCodeEnum getEnumByName(String enumName) {
        TransferNoCodeEnum[] values = TransferNoCodeEnum.values();
        TransferNoCodeEnum repairEnum = null;

        for (TransferNoCodeEnum value : values) {
            if (value.getEnumName().equals(enumName)) {
                repairEnum = value;
            }
        }
        return repairEnum;
    }

    public String getEnumName() {
        return enumName;
    }

    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }

    public static String getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
        TransferNoCodeEnum[] values = TransferNoCodeEnum.values();
        for (TransferNoCodeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)
                    && Objects.equals(value.getEnumName(), enumName)) {
                return value.getCode();
            }
        }
        return null;
    }

    public static Map<String, String> getEnumByDescription() {
        Map<String, String> enumMap = new HashMap<String, String>();
        TransferNoCodeEnum[] values = TransferNoCodeEnum.values();
        for (TransferNoCodeEnum value : values) {
        	enumMap.put(value.getCode(), value.getEnumName());
        }
        return enumMap;
    }
    
    public static Map<String, String> getEnumByDescription(String enumDescription) {
        Map<String, String> enumMap = new HashMap<String, String>();
        TransferNoCodeEnum[] values = TransferNoCodeEnum.values();
        for (TransferNoCodeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                enumMap.put(value.getCode(), value.getEnumName());
            }
        }
        return enumMap;
    }

    public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        TransferNoCodeEnum[] values = TransferNoCodeEnum.values();
        for (TransferNoCodeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                Map<String, Object> enumMap = new HashMap<String, Object>(2);
                enumMap.put("code", value.getCode());
                enumMap.put("name", value.getEnumName());
                list.add(enumMap);
            }
        }
        return list;
    }
}
